import React, {Component} from 'react';
import {Router, Route, hashHistory, IndexRedirect, browserHistory, IndexRoute} from 'react-router';
// 引入redux
import {connect} from 'react-redux'
import *as iframeRouterAction from '../../../action/iframeRouter.js'
import {bindActionCreators} from 'redux'

import {Layout, Menu, Breadcrumb, Icon, Button, Modal, Table} from 'antd';
import '../../../style/index.less';
import Slider from '../../../components/SiderCustom/SiderCustom';
import HeaderCustom from '../../../components/HeaderComponent/HeaderCustom';
import List from './list'


const {Content, Footer} = Layout;
const SubMenu = Menu.SubMenu;

class Home extends Component {
    constructor(props) {
        super(props);

        this.state = {
            tabList: [],//tab值数组
            activeKey: '',
            columns: [{
                title: '页面ID',
                dataIndex: 'name',
            }, {
                title: '页面名称',
                dataIndex: 'age',
            }, {
                title: '页面类型',
                dataIndex: 'address1',
            }, {
                title: '状态',
                dataIndex: 'address2',
                width: 100
            }, {
                title: '活动起止时间',
                dataIndex: 'address3',
            }, {
                title: '创建人/创建时间',
                dataIndex: 'address4',
            }, {
                title: '修改人/修改时间',
                dataIndex: 'address5',
            }, {
                title: '操作',
                dataIndex: 'address6',
                render(text, record) {
                    return <p>
                        <a href="http://qacms.shangpin.com/HomePage" target="_blank">配置</a>
                        {/*<a>编辑页面</a>*/}
                        {/*<a>预览</a>*/}
                    </p>
                }
            },
            ],
            data: [
                {
                    key: 1,
                    name: `Edward King `,
                    age: 32,
                    address1: `London, Park Lane no. `,
                    address2: `在线 `,
                    address3: `London, Park Lane no. `,
                    address4: `London, Park Lane no. `,
                    address5: `London, Park Lane no. `,
                    address6: `London, Park Lane no. `,
                },
                {
                    key: 2,
                    name: `Edward King `,
                    age: 32,
                    address1: `London, Park Lane no. `,
                    address2: `在线 `,
                    address3: `London, Park Lane no. `,
                    address4: `London, Park Lane no. `,
                    address5: `London, Park Lane no. `,
                    address6: `London, Park Lane no. `,
                },
                {
                    key: 3,
                    name: `Edward King `,
                    age: 32,
                    address1: `London, Park Lane no. `,
                    address2: `在线 `,
                    address3: `London, Park Lane no. `,
                    address4: `London, Park Lane no. `,
                    address5: `London, Park Lane no. `,
                    address6: `London, Park Lane no. `,
                }
            ],
            title:''

        };

    }
    setTitle=(title)=>{
       this.setState({
           title:title
       })
    }
    render() {
        const {title} =this.state;
        // console.log(this.state.tabList)
        return (
            <Layout>
                {/* <Button type="primary" onClick={this.buttonTaped.bind(this)} style={{"width":"10%"}}>调用子工程</Button> */}
                {/* 左边导航 */}
                <Slider onItemSelected={this._onMenuItemSelected} onCollapsed={this.state.collapsed}
                        sliderLogoutAction={this.logout}/>
                {/* <div>{this.state.tabList}</div> */}
                <Layout>
                    <HeaderCustom path={{url: 'home', name: title}}/>
                    <Content style={{padding: 10}} className="content">
                        {this.props.children && React.cloneElement(this.props.children, {
                            setTitle: this.setTitle,
                        })}
                    </Content>
                </Layout>




            </Layout>
        )
    }
}

function mapStateToProps(state) {
    return {
        iframeRouter: state.iframeRouter
    }

}

function mapDispatchToProps(dispatch) {
    return {
        iframeRouterAction: bindActionCreators(iframeRouterAction, dispatch)
    }
}

export default connect(
    mapStateToProps,
    mapDispatchToProps
)(Home)